﻿Public Class Form1
#Region "Declare Arrays for Found Files and Found Dirs"
    Public FoundFiles As New ArrayList
    Public FoundDirs As New ArrayList
#End Region

#Region "Declaration of Arrays for Folders and Files"
    ' Worms/Tojans Files.
    Dim Worms_Files() As String = {"c:\Program Files\Archive.exe", "c:\Program Files\Archive.exe", "c:\avtest.txt"}
    ' Worms/Tojans Directories - Full Path.
    Dim Worms_Dirs() As String = {"c:\Program Files\aolx", "c:\Program Files\BTV", "c:\avtest"}

    ' Spyware Files.
    Dim Spyware_Files() As String = {"C:\Program Files\AdStatComm.dll", "C:\Program Files\0er8k4va\0er8k4va.exe", _
                                     "C:\WINDOWS\System32\Mkfxut.exe", "C:\WINDOWS\system32\pkdacs.exe", _
                                     "C:\WINDOWS\System32\ywrqku.exe", "C:\windows\system32\msnavc32.exe", _
                                     "C:\Program Files\AutoUpdate\AutoUpdate.exe", "C:\WINDOWS\System32\vwix32.exe", _
                                     "C:\WINDOWS\System32\winntcreate.exe", "C:\WINDOWS\System32\sysmonnt.exe", _
                                     "C:\WINDOWS\System32\winhcek32.exe", "C:\WINDOWS\System32\qlykdnb.dll", _
                                     "C:\WINDOWS\System32\rypgvtoimrl.exe", "C:\WINDOWS\System32\spwgoc.exe", _
                                     "C:\windows\system32\msnavc32.exe", "C:\WINDOWS\System32\sysmonnt", _
                                     "C:\Program Files\hpdll\hpdll.exe", "C:\WINDOWS\System32\w?wexec.exe", _
                                     "C:\WINDOWS\isrvs\ffisearch.exe", "c:\Program Files\Autosearch.dll", _
                                     "c:\Program Files\Archive.exe", "c:\Program Files\Archive.exe"}
    'Spyware Directories - Full Path.
    Dim Spyware_Dirs() As String = {"c:\Program Files\180 SearchAssistant", "c:\Program Files\2Search", "c:\Program Files\5whgue21", _
                                    "c:\Program Files\aolx", "c:\Program Files\ACM", "c:\Program Files\Browser Pal", _
                                    "c:\Program Files\Activity Keylogger", "c:\Program Files\Activity Logger", _
                                    "c:\Program Files\Actual Spy", "c:\Program Files\AdvSearch", "c:\Program Files\AppsTraka", _
                                    "c:\Program Files\Ardamax Keylogger", "c:\Program Files\Auto Keylogger", _
                                    "c:\Program Files\BazookaBar", "c:\Program Files\Blackbox7", "c:\Program Files\Blackbox7", _
                                    "c:\Program Files\BTV"}
    ' Adware Files.
    Dim Adware_Files() As String = {"c:\Program Files\AdStatComm.dll", "C:\Program Files\0er8k4va\0er8k4va.exe", _
                                    " C:\WINDOWS\System32\Mkfxut.exe", " C:\WINDOWS\system32\pkdacs.exe", _
                                    "C:\WINDOWS\System32\ywrqku.exe", " C:\windows\system32\msnavc32.exe", _
                                    "C:\Program Files\AutoUpdate\AutoUpdate.exe", " C:\WINDOWS\System32\winntcreate.exe", _
                                    "C:\WINDOWS\System32\vwix32.exe", " C:\WINDOWS\System32\sysmonnt.exe", _
                                    "C:\WINDOWS\System32\winhcek32.exe", " C:\WINDOWS\System32\qlykdnb.dll", _
                                    "C:\WINDOWS\System32\rypgvtoimrl.exe", " C:\WINDOWS\System32\spwgoc.exe ", _
                                    "C:\windows\system32\msnavc32.exe", " C:\WINDOWS\System32\sysmonnt", _
                                    "C:\Program Files\hpdll\hpdll.exe ", " C:\WINDOWS\System32\w?wexec.exe", _
                                    "C:\WINDOWS\isrvs\ffisearch.exe", "c:\Program Files\Autosearch.dll"}
    'Adware Directories - Full Path.
    Dim Adware_Dirs() As String = {"c:\Program Files\180 SearchAssistant", "c:\Program Files\2Search", "c:\Program Files\5whgue21", _
                                   "c:\Program Files\aolx", "c:\Program Files\ACM", "c:\Program Files\Browser Pal", _
                                   "c:\Program Files\Activity Keylogger", "c:\Program Files\Activity Logger", _
                                   "c:\Program Files\Actual Spy", "c:\Program Files\AdvSearch", "c:\Program Files\AppsTraka", _
                                   "c:\Program Files\Ardamax Keylogger", "c:\Program Files\Auto Keylogger", _
                                   "c:\Program Files\BazookaBar", "c:\Program Files\Blackbox7", "c:\Program Files\Blackbox7", _
                                   "c:\Program Files\BTV"}

#End Region

#Region "Other Declarations"
    ' Holds the count to how many of each is found.  Used for form 2.
    Public VirusesFound As Integer = 0
    Public SpywareFound As Integer = 0
    Public AdwareFound As Integer = 0
    Dim FileDirCount As Integer = 0
    Dim FileCount As Integer = 0
#End Region

#Region "When Program Loads"
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        ' Select first option on program start.
        ComboBox1.SelectedIndex = 0
    End Sub
#End Region

#Region "Scan Button"
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        ' Clear FoundFiles and FoundDirs Arrays for each time Scan button is clicked.
        FoundDirs.Clear()
        FoundFiles.Clear()
        ' Reset FileDirCount and FileCount to 0.
        FileDirCount = 0
        FileCount = 0
        ' Reset Progress Bar Value.
        ProgressBar1.Value = 0
        ' Set ProgressBar1 Maximum.
        Select Case ComboBox1.SelectedIndex
            Case 0
                ProgressBar1.Maximum = Worms_Dirs.Length + Worms_Files.Length
            Case 1
                ProgressBar1.Maximum = Spyware_Dirs.Length + Spyware_Files.Length
            Case 2
                ProgressBar1.Maximum = Adware_Dirs.Length + Adware_Files.Length
        End Select

        'Start Timer.
        Timer1.Enabled = True
        label3.Text = "Scan Started"
        'Enable STOP SCAN button, Disable SCAN and CLEAN VIRUSES button.
        Button1.Enabled = False
        Button2.Enabled = False
        Button3.Enabled = True
    End Sub
#End Region

#Region "Registration, Yet to do"
    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        ' Registration Form.
        'Form3.Show()
    End Sub
#End Region

#Region "Clean Viruses Button"
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        If FoundDirs.Count Or FoundFiles.Count = 0 Then
            MessageBox.Show("There are either no viruses found or you have not scanned., ", "Uh-Oh", MessageBoxButtons.OK, MessageBoxIcon.Information)
        Else
            Me.Hide()
            Form2.Show()
        End If
    End Sub
#End Region

#Region "The Main Method, File and Directory Search, ProgressBar etc"
    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        ' Loop through each file/dir on each tick of the timer.  Currently set to 500, any lower the message box appears before Bar has finished.
        Select Case ComboBox1.SelectedIndex
            Case 0
                If FileCount < Worms_Files.GetUpperBound(0) Then
                    If IO.File.Exists(Worms_Files(FileCount)) Then
                        FoundFiles.Add(Worms_Files(FileCount))
                        VirusesFound += 1
                    End If
                End If
                If FileDirCount < Worms_Dirs.GetUpperBound(0) Then
                    If IO.Directory.Exists(Worms_Dirs(FileDirCount)) Then
                        FoundDirs.Add(Worms_Dirs(FileDirCount))
                        VirusesFound += 1
                    End If
                End If

            Case 1
                If FileCount < Spyware_Files.GetUpperBound(0) Then
                    If IO.File.Exists(Spyware_Files(FileCount)) Then
                        FoundFiles.Add(Spyware_Files(FileCount))
                        VirusesFound += 1
                    End If
                End If
                If FileDirCount < Spyware_Dirs.GetUpperBound(0) Then
                    If IO.Directory.Exists(Spyware_Dirs(FileDirCount)) Then
                        FoundDirs.Add(Spyware_Dirs(FileDirCount))
                        VirusesFound += 1
                    End If
                End If

            Case 2
                If FileCount < Adware_Files.GetUpperBound(0) Then
                    If IO.File.Exists(Adware_Files(FileCount)) Then
                        FoundFiles.Add(Adware_Files(FileCount))
                        VirusesFound += 1
                    End If
                End If
                If FileDirCount < Adware_Dirs.GetUpperBound(0) Then
                    If IO.Directory.Exists(Adware_Dirs(FileDirCount)) Then
                        FoundDirs.Add(Adware_Dirs(FileDirCount))
                        VirusesFound += 1
                    End If
                End If
        End Select

        ' Has the ProgressBar value reached its maximum?  if so stop timer and show message, otherwise keep going.
        If ProgressBar1.Value = ProgressBar1.Maximum Then
            Timer1.Enabled = False
            label3.Text = "Scan Completed"
            MessageBox.Show("Your computer has been scanned!  Click the Clean Viruses Button, and we'll show you the results!", "Result", MessageBoxButtons.OK, MessageBoxIcon.Information)
            Button1.Enabled = True
            Button2.Enabled = True
            Button3.Enabled = False
        Else
            FileDirCount += 1
            ProgressBar1.Value += 1
        End If
    End Sub
#End Region

#Region "Stop Scan Button"
    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        Timer1.Enabled = False
        label3.Text = "Scan Stopped"
        ProgressBar1.Value = 0
        Button1.Enabled = True
        Button2.Enabled = True
        Button3.Enabled = False
    End Sub
#End Region

End Class
